<template>
  <div>
    <el-menu
      default-active="2"
      class="el-menu-vertical-demo"
      @open="handleOpen"
      @close="handleClose"
    >
      <el-submenu
        v-for="menuItem in menuList"
        :key="menuItem.titleId"
        :index="menuItem.titleId"
        @click="changeMenuItem(menuItem)"
      >
        <template slot="title">
          <span>{{ menuItem.name }}</span>
        </template>
        <el-menu-item-group>
          <el-menu-item
            index="menuLevelItem.levelId"
            v-for="menuLevelItem in menuLevelList"
            :key="menuLevelItem.levelId"
            @click="changeMenuItem(menuLevelItem)"
            >{{ menuLevelItem.name }}</el-menu-item
          >
        </el-menu-item-group>
      </el-submenu>
    </el-menu>
  </div>
</template>
<script>
export default {
  data() {
    return {
      menuList: [
        { titleId: 1, name: "应用开发" },
        { titleId: 2, name: "设备开发" },
        { titleId: 3, name: "样例共建排行榜" },
      ],
      menuLevelList: [
        { levelId: 1, name: "入门级" },
        { levelId: 2, name: "初级" },
        { levelId: 3, name: "中级" },
        { levelId: 4, name: "高级" },
      ],
      menuListId: 1,
    };
  },
  created() {},
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    changeMenuItem(menuItem) {
      this.menuListId = menuItem.titleId;
    },
    changeMenuItem(menuLevelItem) {
      this.$router.push({ name: "mainText" });
    },
  },
  watch: {},
};
</script>
<style lang="less" scoped>
@media screen and (max-width: 540px) {
}
</style>
